package locality;

import static org.junit.Assert.*;

import java.util.Arrays;

import genome.CGP;

import org.junit.Before;
import org.junit.Test;


public class CoSymbolicRegressionTest {
	CoSymbolicRegression csr;
	CGP g1;
	CGP g2;

	@Before
	public void setUp() throws Exception {
		double[] x = {0.0};
		g1 = new CGP(x,6);
		g2 = new CGP(x,6);
		int[] genome1 = {0,0,0,1,1,0}; //4x
		int[] genome2 = {0,0,0,0,0,0}; //2x
		g1.setGenome(genome1);
		g2.setGenome(genome2);
		System.out.println(g1.toMathString());
		System.out.println(g2.toMathString());
		
		csr = new CoSymbolicRegression(g1, g2);
	}

	@Test
	public void testCO1() {
		double outcome = csr.CO1();
		assertTrue(outcome==1.0);
	}

	@Test
	public void testSymbolicValues() {
		double[] vals = csr.symbolicValues(g1);
		for (int i = 0; i < vals.length; i++) {
			System.out.println(vals[i]);
		}
		
		double[] expectedValues = {-4.0,-3.2,-2.4,-1.6,-0.8,0.0,0.8,1.6,2.4,3.2,4.0};
		assertTrue(Arrays.equals(vals, expectedValues));
	}

}
